﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>


<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
IF  Request.QueryString("Action")="login" Then
	call login
else
	call index
end if
end Function



Function index
	dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1
	dim rs,sql,Runtxt,id,classid
    		classid = Request("classid")
    		If classid = "" Then classid = 0
   		If Not IsNumeric(classid) Then classid = 0
    		classid = CLng(classid)
    		If classid < 0 Then classid = 0

	Runtxt=qingtian.RunStr
    		id = Request("id")    
    		If id = "" Then id = 1
   		If Not IsNumeric(id) Then id = 1
    		id = CLng(id)
    		If id < 1 Then id = 1

%>
	<card title="编辑友链"><p align="left">
<%
		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 *  FROM qingtian_link_list where id="&id&""
		rs.open sql,conn,1,1
		if not (rs.eof and rs.bof) then
		dim rs2,sql2,i
%>
   	分类<select name="cid<%=Runtxt%>" value="<%=rs("classid")%>">
	<%
	  set rs2=server.CreateObject("adodb.recordset")
	  sql2="select id,name from qingtian_link_class order by pid asc"
	  rs2.open sql2,conn,1,1
	  if not (rs2.bof and rs2.eof) then
	  For i=1 to rs2.RecordCount
		%>
		<option value="<%=rs2("id")%>"><%=qingtian.utf8(rs2("name"))%></option>
		<%
	  Rs2.MoveNext
	  Next

	  end if
	  Rs2.close
	  set rs2=nothing
	%>
	</select><br/>

	网站名称：<input emptyok="true"  name="name<%=Runtxt%>" type="text"  value="<%=qingtian.FormatEdit(rs("name"))%>" maxlength="50"  /><br/>
	网站短名：<input emptyok="true"  name="mainname<%=Runtxt%>" type="text"  value="<%=qingtian.FormatEdit(rs("main"))%>" maxlength="2" />最多2个汉字<br/>
	网站地址：<input emptyok="true"  name="urls<%=Runtxt%>" type="text"  value="<%=qingtian.FormatEdit(rs("urls"))%>" maxlength="255" /><br/>
   	审核<select name="show<%=Runtxt%>" value="<%=rs("show")%>">
	<option value="1">通过</option>
	<option value="0">不通过</option>
	</select><br/>


	<anchor>确定提交
    	<go href="editlinklist.asp?Action=login&amp;page=<%=page%>&amp;id=<%=id%>&amp;classid=<%=classid%>&amp;sid=<%=sid%>" method='post'>
        <postfield name="cid" value="$(cid<%=Runtxt%>)"/>
        <postfield name="name" value="$(name<%=Runtxt%>)"/>
        <postfield name="mainname" value="$(mainname<%=Runtxt%>)"/>
        <postfield name="urls" value="$(urls<%=Runtxt%>)"/>
        <postfield name="show" value="$(show<%=Runtxt%>)"/>
     	</go>
	</anchor><br/>
<%
		end if
		rs.Close
		Set rs = Nothing
%>

-------------<br/>
<a href='linklist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>返回友链管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
End Function


Function login
	dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1

		dim rs,sql,errs,id,classid
    		classid = Request("classid")
    		If classid = "" Then classid = 0
   		If Not IsNumeric(classid) Then classid = 0
    		classid = CLng(classid)
    		If classid < 0 Then classid = 0

		dim cid,name,mainname,urls,show
        cid=Request.form("cid")
        name=Request.form("name")
        mainname=Request.form("mainname")
        urls=Request.form("urls")
        show=Request.form("show")
 

    		id = Request("id")    
    		If id = "" Then id = 1
   		If Not IsNumeric(id) Then id = 1
    		id = CLng(id)
    		If id < 1 Then id = 1
		if show="" then show=0
		errs=""

		if len(name)=0  then errs=errs & "网站名称不能为空<br/>"
		if cid=""  then errmsg=errmsg&"分类不能为空<br/>"
		if mainname=""  then errmsg=errmsg&"网站短名不能为空<br/>"
		if urls=""  then errmsg=errmsg&"网站地址不能为空<br/>"


	%>
	<card id="login" title="编辑友链" ontimer="linklist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>"><timer value="20"/>
		<p align="left">
	<%
	IF len(errs)=0 then


		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 *  FROM qingtian_link_list where id="&id&""
		rs.open sql,conn,1,3
		if not (rs.eof and rs.bof) then

				rs("name")=name
				if instr(urls,"http://")>0 then
				rs("urls")=urls
				else
				rs("urls")="http://" & urls
				end if
				rs("main")=mainname
				rs("classid")=cid
				rs("show")=show
		rs.update()
		end if
		rs.Close
		Set rs = Nothing
		%>编辑友链成功!<br/><%

	else%>
		<%=errs%>
		<a href="editlinklist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;id=<%=id%>&amp;sid=<%=sid%>">返回修改</a><br/>
<%	end if
%>
<a href='linklist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>返回友链管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function 


%>
